import { Injectable } from "@angular/core";
import { HttpClient, HttpParams } from "@angular/common/http";
@Injectable({
  providedIn: 'root'
})
export class SellChangecodeRecordService {

  serviceUrls = {
    changeCodeListUrl: '/couponExchange/list', // 兑换码记录列表
    changeCodeInfoUrl: '/couponExchange/info', // 根据批次号统计兑换码信息
    cancelChangeCodeUrl: '/couponExchange/cancel/', // 作废兑换码
    exportChangeCodeUrl: '/couponExchange/export', // 导出兑换码记录
  }

  constructor(public httpClient: HttpClient) { }

  // 兑换码记录List
  getChangeCodeList(params: any) {
    return this.httpClient.get(this.serviceUrls.changeCodeListUrl, { params }).toPromise();
  }

  // 根据批次号统计兑换码信息
  getChangeCodeInfoData(params: any) {
    return this.httpClient.get(this.serviceUrls.changeCodeInfoUrl, { params }).toPromise();
  }

  // 作废兑换码
  cancelChangeCodeData(params: any) {
    return this.httpClient.post(this.serviceUrls.cancelChangeCodeUrl, params).toPromise();
  }

  // 导出兑换码记录
  exportChangeCodeData(params: any) {
    return this.httpClient.get(this.serviceUrls.exportChangeCodeUrl, { params, responseType: 'blob' }).toPromise();
  }
}
